<?php

namespace app\shop\controller;

use buildView\Nestable;
use think\Controller;
use buildView\Form;
use app\common\model\ShopStudyCate;

/**
 * 学历年级管理
 * Class StudyCate
 * @package app\admin\controller
 */
class StudyCate extends Controller
{
    /**
     * 列表
     * @auth true
     * @menu true
     * @return string
     */
    public function index()
    {
        $nestable = new Nestable(new ShopStudyCate,'pid','title','sort');
        $nestable->setTitle('年级列表');
        $nestable->display(function ($data){
            return $data['title'];
        });
        $nestable->setFromOpen();
        return $nestable->view();
    }
    /**
     * 添加/编辑
     * @auth true
     * @menu true
     * @return string
     */
    public function form()
    {
        $form = new Form(new ShopStudyCate);
        $options = ShopStudyCate::buildTreeSelectOptions();
        $form->select('pid','父级')->options([
                '0'=>'顶级'
            ]+$options)->search(false)->required();
        $form->text('title','名称')->required();
        return $form->view();
    }


}
